#include <cstdio>

int main() {
	const int MAXN = 100010;
	int school[MAXN] = {0};
	int T;
	int schoolId, schoolScore;
	int maxId = -1, max = -1;
	scanf("%d", &T);

	for (int i = 0; i < T; i++) {
		scanf("%d %d", &schoolId, &schoolScore);
		school[schoolId] += schoolScore;
	}

	for (int i = 1; i <= T; i++) {
		if (max < school[i]) {
			max = school[i];
			maxId = i;
		}
	}

	printf("%d %d\n", maxId, max);

	return 0;
}
